package com.fujifilm.project.plan.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fujifilm.project.plan.entity.ProjectGroup;
import com.fujifilm.project.plan.service.IProjectGroupService;
import com.fujifilm.project.plan.utils.HttpResponse;
import com.fujifilm.project.plan.vo.request.RequestRecords.ProjectGroupBatchDeleteRequest;
import com.fujifilm.project.plan.vo.request.RequestRecords.ProjectGroupDeleteRequest;
import com.fujifilm.project.plan.vo.request.RequestRecords.ProjectGroupInfoRequest;
import com.fujifilm.project.plan.vo.request.RequestRecords.ProjectGroupPageListRequest;
import com.fujifilm.project.plan.vo.request.RequestRecords.ProjectGroupSaveRequest;
import com.mybatisflex.core.paginate.Page;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/projectGroup")
@Slf4j
@RequiredArgsConstructor
public class ProjectGroupController {
    private final IProjectGroupService projectGroupService;

    @PostMapping("/pageList")
    public HttpResponse<Page<ProjectGroup>> pageList(@RequestBody ProjectGroupPageListRequest req) {
        return HttpResponse.success(projectGroupService.pageList(req));
    }

    @PostMapping("/save")
    public HttpResponse<Void> save(@RequestBody ProjectGroupSaveRequest req) {
        projectGroupService.save(req);
        return HttpResponse.success(null);
    }

    @PostMapping("/delete")
    public HttpResponse<Void> delete(@RequestBody ProjectGroupDeleteRequest req) {
        // 假设有一个删除方法
        projectGroupService.delete(req.id());
        return HttpResponse.success(null);
    }

    @PostMapping("/batchDelete")
    public HttpResponse<Void> batchDelete(@RequestBody ProjectGroupBatchDeleteRequest req) {
        // 假设有一个删除方法
        projectGroupService.batchDelete(req.ids());
        return HttpResponse.success(null);
    }

    @PostMapping("/info")
    public HttpResponse<ProjectGroup> info(@RequestBody ProjectGroupInfoRequest req) {
        return HttpResponse.success(projectGroupService.info(req.id()));
    }
}
